package com.example.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface FavoriteMapper {

    @Insert("insert into tb_favorite(employeeId, userId) values(#{employeeId}, #{userId})")
    int addFavorite(@Param("employeeId") Integer employeeId, @Param("userId") Integer userId);

    @Delete("delete from tb_favorite where employeeId = #{employeeId} and userId = #{userId}")
    int removeFavorite(@Param("employeeId") Integer employeeId, @Param("userId") Integer userId);

    @Select("select count(*) from tb_favorite where employeeId = #{employeeId}")
    int getFavoriteNumByEmployeeId(@Param("employeeId") Integer employeeId);

    @Select("select employeeId from tb_favorite where userId = #{userId}")
    List<Integer> getFavoriteListByUserId(@Param("userId") Integer userId);
}
